package org.hagen.mmia.yars.agent;

import java.util.ArrayList;

public class ResultList {

	private int					totalHits = 0;
	
	public ArrayList<String>	viewedSet = null;
	public ArrayList<String>	relevantSet = null;
	public ArrayList<String>	notRelevantSet = null;
	public ArrayList<String>	retrievedSet = null;

	public void destruct() {
		relevantSet.clear();
		relevantSet = null;

		notRelevantSet.clear();
		notRelevantSet = null;
		
		retrievedSet.clear();
		retrievedSet = null;
		
		viewedSet.clear();
		viewedSet = null;
		
		totalHits = 0;
	}
	
	public ResultList( ) {
		retrievedSet   = new ArrayList<String>();
		relevantSet    = new ArrayList<String>();
		notRelevantSet = new ArrayList<String>();
		viewedSet      = new ArrayList<String>();
	}
	
	public double getFreshness() {
		return ( double )totalHits / ( double )viewedSet.size();
	}

	public double getRelevance() {
		return ( double )relevantSet.size() / ( double )viewedSet.size();
	}
	
	public void setTotalHits(int totalHits) {
		this.totalHits = totalHits;
	}
	
	public void addRetrieved( String docID ) {
		retrievedSet.add( docID );
	}
	
	public void addRelevant( String docID ) {
		relevantSet.add( docID );
	}
	
	public void addViewed( String docID ) {
		viewedSet.add( docID );
	}

	public void addNotRelevant( String docID ) {
		notRelevantSet.add( docID );
	}
}